//
//  PriceDetailViewController.swift
//  ParkManage
//
//  Created by cf on 2020/9/22.
//  Copyright © 2020 diligrp. All rights reserved.
//

import UIKit

class PriceDetailViewController: BaseViewController {

    @IBOutlet weak var dateLabel: UILabel!
    
    @IBOutlet weak var detailView: UIView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var goodsNameLabel: UILabel!
    @IBOutlet weak var priceLabel: UILabel!
    @IBOutlet weak var cutLine: UIView!
    @IBOutlet weak var cardNoLabel: UILabel!
    @IBOutlet weak var customerLabel: UILabel!
    @IBOutlet weak var tradeTypeLabel: UILabel!
    @IBOutlet weak var minPriceLabel: UILabel!
    @IBOutlet weak var tradeNoLabel: UILabel!
    
    @IBOutlet weak var remarksView: UIView!
    @IBOutlet weak var remarksTextField: UITextField!
    
    @IBOutlet weak var refuseButton: UIButton!
    @IBOutlet weak var agreeButton: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        title = "价格详情"
        
        setUITheme()
        remarksTextField.addTarget(self, action: #selector(textFieldValueChange(textfield:)), for: .editingChanged)
    }
    
    override func viewDidLayoutSubviews() {
        detailView.setShadowWith(bounds: detailView.bounds)
        remarksView.setShadowWith(bounds: remarksView.bounds)
        cutLine.width = Configs.Dimensions.screenWidth - 60
        cutLine.transLineToDash()
    }
    
    func setUITheme() {
        refuseButton.makeRoundedCorners(22.5)
        agreeButton.makeRoundedCorners(22.5)
    }
    
    @IBAction func refuse(_ sender: UIButton) {
        
    }
    
    @IBAction func agree(_ sender: UIButton) {
        
    }
    
    @objc func textFieldValueChange(textfield: UITextField) {
        
        let remarks: String = textfield.text ?? ""
        
        if textfield.markedTextRange == nil {
            if remarks.count > 10 {
                let index = remarks.index(remarks.startIndex, offsetBy: 10)
                textfield.text = String(remarks[..<index])
            }
        }
    }
}
